using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace blogapi
{
    public partial class servery : Form
    {
        public servery(publy pb,pages pag,nastaveni nast)
        {
            InitializeComponent();
            pbb = pb;
            pg = pag;
            nas = nast;
            polozka = new publikacepolozky(pb,pag,this,nast);
        }

        nastaveni nas;
        publy pbb;
        pages pg;
        public void nacti()
        {
            listView1.Items.Clear();
            for (int i = 0; i < pg.mozn.Count; i++)
            {
                blogs bg = (blogs)pg.mozn[i];
                ListViewItem l = new ListViewItem(bg.tabulka());
                l.Tag = i;
                l.Checked = bg.vybrat;
                listView1.Items.Add(l);
            }
        }

        private void menuItem1_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        publikacepolozky polozka;
        private void menuItem2_Click(object sender, EventArgs e)
        {
            bool projdu = false;
            for (int i = 0; i < listView1.Items.Count; i++)
            {
                if (listView1.Items[i].Checked==true)
                {
                    projdu = true;
                    break;
                }
            }
            if (!projdu)
            {
                MessageBox.Show(nas.getlang("zvolteservery"), nas.getlang("publikacepriss"));
                return;
            }

            bool doitnow = false;
            if (nas.dotazovatse)
            {
                if (DialogResult.OK == MessageBox.Show(nas.getlang("upozornenipripojeni"), nas.getlang("upozorneni"), MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1))
                {
                    doitnow = true;
                }
            }
            else
            {
                doitnow = true;
            }
            if (doitnow)
            {
                polozka.Show();
                polozka.odstartuj();
                this.Hide();
            }
        }

        public void setlang()
        {
            polozka.setlang();
            menuItem1.Text = nas.getlang("zpet");
            menuItem2.Text = nas.getlang("publikovat");
            columnHeader1.Text = nas.getlang("server");
            columnHeader2.Text = nas.getlang("user");
            label1.Text = nas.getlang("zvolteucet");
            Text = "W - "+nas.getlang("zvolucet");
        }
    }
}